package charbai;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class ReaberDemo {
	public static void main(String[] args) {
		char[] data = new char[10];
		Reader reaber = null;
		try {
			reaber = new FileReader("E:/test.txt");
			int szie = 0;
			while ((szie = reaber.read(data)) >= 0) {
				String aa = new String(data, 0, szie);
				System.out.println(aa);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				reaber.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		Reader der=null;
		Writer ter=null;
		char[] data1=new char[100];
		try {
			der=new FileReader("e:/1.jpg");
			ter=new FileWriter("d:/2.jpg");
			int size1=0;
			while ((size1=der.read(data1))>=0) {
				ter.write(data1, 0, size1);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				der.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				ter.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
